home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK2.toast / Development Kits (Disc 2) / ScriptX / Code Samples / colrpick / loadme.sx < prev    next >
Encoding:
Text File  |  1996-05-21  |  4.1 KB  |  116 lines  |  [TEXT/ttxt]

  1. --<<<-
  2. --*******************************************************************************
  3. --*          Demo for:    ColorPicker
  4. --*    Required files: colrpick.sx
  5. --*            Author:    Su Quek - Kaleida Labs, Inc.
  6. --*-----------------------------------------------------------------------------*
  7. --*       Description: This script demonstrates how to create and use a color
  8. --*                    picker.
  9. --*                    When you run "colrpick.sxt", you should see a window
  10. --*                    with a colorpicker.  Click on a colored square in the
  11. --*                    colorpicker to change the fill of the window. 
  12. --*
  13. --*             Notes: The colorChanged method MUST be defined as a method of 
  14. --*                    the ColorPicker's manager
  15. --*******************************************************************************
  16.  
  17. module ColorPickerModule
  18.     uses ScriptX
  19. end
  20.  
  21. in module ColorPickerModule
  22.  
  23. --*=============================================================================*
  24. --* Load required files
  25. --*=============================================================================*
  26. -- Load ColorMapShape and ColorPicker
  27. fileIn theScriptDir name:"colrpick.sx"
  28.  
  29.  
  30. --*=============================================================================*
  31. --*    Define Demo 
  32. --*=============================================================================*
  33. class Demo (Window)
  34. end
  35.  
  36. --*=============================================================================*
  37. --*       Method name:    colorChanged
  38. --*             Class:    Demo
  39. --*             Usage: colorChanged self newBrush
  40. --*                        newBrush    - Brush
  41. --*-----------------------------------------------------------------------------*
  42. --*       Description: Changes the fill and stroke of the demo window.
  43. --*=============================================================================*
  44. method colorChanged self {class Demo} newBrush ->
  45. (
  46.     self.fill := newBrush
  47.     self.stroke := newBrush
  48. )
  49.  
  50. --*=============================================================================*
  51. --*       Method name:    init
  52. --*             Class:    Demo
  53. --*             Usage: init self 
  54. --*-----------------------------------------------------------------------------*
  55. --*       Description: Creates a 300x300 window.
  56. --*=============================================================================*
  57. method init self {class Demo} #rest args ->
  58. (
  59.     -- Create a 300x300 window 
  60.     apply nextMethod self boundary:(new Rect x2:300 y2:300) \
  61.                           centered:true \
  62.                           name:"Pick a Color" args
  63.     return self
  64. )
  65.  
  66. --*=============================================================================*
  67. --*       Method name:    afterInit
  68. --*             Class:    Demo
  69. --*             Usage: afterInit self 
  70. --*-----------------------------------------------------------------------------*
  71. --*       Description: Makes the color picker and appends it to the demo window.
  72. --*=============================================================================*
  73. method afterInit self {class Demo} #rest args ->
  74. (                          
  75.     --*=========================================================================*
  76.     --* Create the color picker.
  77.     --*=========================================================================*
  78.     local cp := new ColorPicker manager:self
  79.     cp.x := cp.y := 10
  80.     
  81.     --*=========================================================================*
  82.     --* Add color picker to the demo window and display it.
  83.     --*=========================================================================*
  84.     prepend self cp
  85.     show self
  86.     
  87.     return self
  88. )
  89.  
  90.  
  91. --*=============================================================================*
  92. --*    Create a title container
  93. --*=============================================================================*
  94. object tc (TitleContainer)
  95.     dir        : theScriptDir
  96.     path    : "colrpick.sxt" 
  97.     name    : "Color Picker"
  98. end        
  99.     
  100. --*=============================================================================*
  101. --*    Create demo
  102. --*=============================================================================*
  103. object win (Demo)
  104.     title:tc
  105. end
  106.  
  107. --*=============================================================================*
  108. --*    Store module in the title container
  109. --*=============================================================================*
  110. append tc (getModule @ColorPickerModule)
  111. tc.startUpAction := (tc ->  load tc[1]
  112.                             show win)
  113.  
  114. close tc
  115. -->>>
  116.